package com.wgtgt.hutool_jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import javax.sql.DataSource;

import cn.hutool.db.DbUtil;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.DSFactory;
import cn.hutool.db.handler.EntityListHandler;
import cn.hutool.db.sql.SqlExecutor;

/**
 * Hello world!
 *
 */
public class App {
	public static void main(String[] args) {
		System.out.println("Hello World!");
		DataSource ds = DSFactory.get();
		Connection conn = null;
		try {
			conn = ds.getConnection();
			List<Entity> entityList = SqlExecutor.query(conn, "select * from t_user limit 10", new EntityListHandler());
			System.out.println(entityList);
			for (Entity entity : entityList) {
				Date date = entity.getDate("create_time");
				System.out.println(entity);
				System.out.println("date = " + date);
				System.out.println("date = " + date.getClass());
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DbUtil.close(conn);
		}
	}
}
